package getproblem

import (
	"fmt"
	"myOJ/datastructure"
	"myOJ/db"
)

func GetArgs(problemTitle string) []datastructure.ProblemArgs {
	pargs := make([]datastructure.ProblemArgs, 0)
	rows, err := db.Dd.Query("SELECT * FROM args WHERE problemTitle='" + problemTitle + "' ORDER BY itsorder")
	if err != nil {
		fmt.Println("GetProblem table problems", err)
		return pargs
	}

	var id, itsorder int
	var ptitle, argname, argtype string
	for rows.Next() {
		rows.Scan(&id, &ptitle, &argname, &itsorder, &argtype)
		pargs = append(pargs, datastructure.ProblemArgs{id, ptitle, argname, itsorder, argtype})
	}
	return pargs
}
